package com.xingchi.tornado.security.handler;

import com.xingchi.tornado.security.model.IUser;
import com.xingchi.tornado.security.model.LoginData;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 装饰器
 *
 * @author xingchi
 * @date 2025/9/17 23:07
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class SessionAttributeServiceDecorator implements SessionAttributeService {

    private final List<SessionAttributeService> sessionAttributeServices;

    @Override
    public void fillSessionAttribute(HttpSession session, LoginData<? extends IUser> loginData) {
        for (SessionAttributeService sessionAttributeService : sessionAttributeServices) {
            sessionAttributeService.fillSessionAttribute(session, loginData);
        }
    }
}
